package edu.vt.ece_3574.amber_alert.database;

import java.util.ArrayList;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.os.AsyncTask;
import android.util.Log;

public class NotifyServerLocationUpdated extends AsyncTask<String, Void, Void> {

	@Override
	protected Void doInBackground(String... callers) {
		for (String caller : callers) {
			//the serial number data to send
			ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
			nameValuePairs.add(new BasicNameValuePair("caller", caller));
			
			try {
				HttpClient httpclient = new DefaultHttpClient();
				HttpPost httppost = new HttpPost(DatabaseHandler.databaseURL + "notifyServerLocationUpdated.php");
				httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
				HttpResponse response = httpclient.execute(httppost); 
				HttpEntity entity = response.getEntity();
				entity.getContent();
			}
			catch(Exception e) {
				Log.e("log_tag", "Error in http connection "+e.toString());
			}
		}
		return null;
	}

}
